﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RealtyManagementSystem.DAL;

namespace RealtyManagementSystem.BLL
{
    /// <summary>
    /// 
    /// </summary>
    public class UsersProvider
    {

        public UsersProvider ()
        {
        }

        public List<aspnet_Users> GetAllUsers ()
        {
            //TODO Not Implemented
            throw new NotImplementedException();
        }

        public List<aspnet_Users> GetUsersByRoleId ( Guid roleID )
        {
            List<aspnet_Users> users;
            using (var dataContext = new realtydbEntities())
            {
                users =
                    (
                   from rol in dataContext.aspnet_Roles.Include("aspnet_Users.aspnet_Membership")
                   from usr in rol.aspnet_Users
                   where rol.RoleId == roleID
                   select usr
                    ).Take(200).ToList();
                return users;
            }
        }


        public void AddNewUser ( aspnet_Users usr)
        {
            using (var dataContext = new realtydbEntities())
            {
                dataContext.AddToaspnet_Users(usr);
                dataContext.SaveChanges();
            }
        }
    }//end class
}
